package cn.yuanqiao.archive.bianjifabu.domain;

import cn.yuanqiao.common.annotation.IdAnnotation;
import cn.yuanqiao.common.utils.SecurityUtils;
import cn.yuanqiao.common.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import cn.yuanqiao.common.core.domain.BaseEntity;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 发布方案对象 A001_YQFABUFANGAN
 *
 * @author yuanqiao
 * @date 2024-03-18
 */
public class Yqfabufangan extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    public static final String BIGTABLENAME = "_YQFABUFANGAN";

    public Yqfabufangan() {
        String tenantCode = SecurityUtils.getTenantCode();
        if(StringUtils.isEmpty(tenantCode)){
            if(SecurityUtils.getLoginUser() != null){
                tenantCode = SecurityUtils.getLoginUser().getSysUser().getTenantCode();
            }
        }
        this.tableName = tenantCode.toUpperCase()+BIGTABLENAME;
    }

    private String tableName;

    /** $column.columnComment */
    //@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()"
    @IdAnnotation
    private Long id;

    /** 门类名称 */
    //@Excel(name = "门类名称")
    private String categoryName;

    /** 审批状态(未知) */
    //@Excel(name = "审批状态(1-取消申请0申请中1办结2被退回-2未审批)")
    private String state;

    /** 发布状态(0未发布1发布) */
    //@Excel(name = "发布状态(0未发布1发布)")
    private String fabuState;

    /** 方案名称 */
    //@Excel(name = "方案名称")
    private String fanganName;

    /** 发布人 */
    //@Excel(name = "发布人")
    private String faburen;

    /** 发布人id */
    //@Excel(name = "发布人id")
    private String faburenId;

    /** 发布网段(1局域网2互联网3政务网) */
    //@Excel(name = "发布网段(1局域网2互联网3政务网)")
    private String fabuWangduan;

    /** 发布内容(1目录2目录全文) */
    //@Excel(name = "发布内容(1目录2目录全文)")
    private String fabuType;

    /** 发布日期 */
    //@Excel(name = "发布日期")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date faburq;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date faburq2;

    /** 发布说明 */
    //@Excel(name = "发布说明")
    private String fabuShuoming;

    /** 分表名 */
    //@Excel(name = "分表名")
    private String subTableName;

    /** 目标系统 */
    //@Excel(name = "目标系统")
    private String mubiaoXitong;

    /** 发布方式(1离线2在线) */
    //@Excel(name = "发布方式(1离线2在线)")
    private String fabuFangshi;

    /** $column.columnComment */
    //@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    private String lastUpdateBy;

    private String lastUpdater;

    private String creator;

    /** $column.columnComment */
    //@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastUpdateTime;

    private String fileFieldIds;

    private String efileFieldIds;

    /** 申请时间 */
    //@Excel(name = "申请时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date shenqingTime;

    public String getLastUpdater() {
        return lastUpdater;
    }

    public void setLastUpdater(String lastUpdater) {
        this.lastUpdater = lastUpdater;
    }

    public Date getFaburq2() {
        return faburq2;
    }

    public void setFaburq2(Date faburq2) {
        this.faburq2 = faburq2;
    }

    public void setCategoryName(String categoryName)
    {
        this.categoryName = categoryName;
    }

    public String getCategoryName()
    {
        return categoryName;
    }

    public void setFabuState(String fabuState)
    {
        this.fabuState = fabuState;
    }

    public String getFabuState()
    {
        return fabuState;
    }
    public void setFanganName(String fanganName)
    {
        this.fanganName = fanganName;
    }

    public String getFanganName()
    {
        return fanganName;
    }

    public void setFaburenId(String faburenId)
    {
        this.faburenId = faburenId;
    }

    public String getFaburenId()
    {
        return faburenId;
    }
    public void setFabuWangduan(String fabuWangduan)
    {
        this.fabuWangduan = fabuWangduan;
    }

    public String getFabuWangduan()
    {
        return fabuWangduan;
    }
    public void setFabuType(String fabuType)
    {
        this.fabuType = fabuType;
    }

    public String getFabuType()
    {
        return fabuType;
    }

    public void setFabuShuoming(String fabuShuoming)
    {
        this.fabuShuoming = fabuShuoming;
    }

    public String getFabuShuoming()
    {
        return fabuShuoming;
    }
    public void setSubTableName(String subTableName)
    {
        this.subTableName = subTableName;
    }

    public String getSubTableName()
    {
        return subTableName;
    }
    public void setMubiaoXitong(String mubiaoXitong)
    {
        this.mubiaoXitong = mubiaoXitong;
    }

    public String getMubiaoXitong()
    {
        return mubiaoXitong;
    }
    public void setFabuFangshi(String fabuFangshi)
    {
        this.fabuFangshi = fabuFangshi;
    }

    public String getFabuFangshi()
    {
        return fabuFangshi;
    }
    public void setLastUpdateBy(String lastUpdateBy)
    {
        this.lastUpdateBy = lastUpdateBy;
    }

    public String getLastUpdateBy()
    {
        return lastUpdateBy;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public Date getShenqingTime() {
        return shenqingTime;
    }

    public void setShenqingTime(Date shenqingTime) {
        this.shenqingTime = shenqingTime;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getFaburen() {
        return faburen;
    }

    public void setFaburen(String faburen) {
        this.faburen = faburen;
    }

    public Date getFaburq() {
        return faburq;
    }

    public void setFaburq(Date faburq) {
        this.faburq = faburq;
    }

    public String getFileFieldIds() {
        return fileFieldIds;
    }

    public void setFileFieldIds(String fileFieldIds) {
        this.fileFieldIds = fileFieldIds;
    }

    public String getEfileFieldIds() {
        return efileFieldIds;
    }

    public void setEfileFieldIds(String efileFieldIds) {
        this.efileFieldIds = efileFieldIds;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    @Override
    public String toString() {
        return "Yqfabufangan{" +
                "tableName='" + tableName + '\'' +
                ", id=" + id +
                ", categoryName='" + categoryName + '\'' +
                ", state='" + state + '\'' +
                ", fabuState='" + fabuState + '\'' +
                ", fanganName='" + fanganName + '\'' +
                ", faburen='" + faburen + '\'' +
                ", faburenId='" + faburenId + '\'' +
                ", fabuWangduan='" + fabuWangduan + '\'' +
                ", fabuType='" + fabuType + '\'' +
                ", faburq=" + faburq +
                ", faburq2=" + faburq2 +
                ", fabuShuoming='" + fabuShuoming + '\'' +
                ", subTableName='" + subTableName + '\'' +
                ", mubiaoXitong='" + mubiaoXitong + '\'' +
                ", fabuFangshi='" + fabuFangshi + '\'' +
                ", lastUpdateBy='" + lastUpdateBy + '\'' +
                ", lastUpdater='" + lastUpdater + '\'' +
                ", creator='" + creator + '\'' +
                ", lastUpdateTime=" + lastUpdateTime +
                ", fileFieldIds='" + fileFieldIds + '\'' +
                ", efileFieldIds='" + efileFieldIds + '\'' +
                ", shenqingTime=" + shenqingTime +
                '}';
    }

    public Map<String, Object> toProcessMap() {
        Map<String, Object> map = new HashMap<>();

        // 使用反射获取实体类的字段信息
        Class<?> clazz = this.getClass();
        Field[] fields = clazz.getDeclaredFields();

        try {
            // 遍历所有字段，获取字段名和字段值，并存储到 Map 中
            for (Field field : fields) {
                field.setAccessible(true); // 设置字段可访问，即使是私有字段也可以获取值
                String fieldName = field.getName();
                Object fieldValue = field.get(this); // 获取字段的值
                map.put(fieldName, fieldValue);
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return map;
    }
}
